package com.twu.biblioteca;

import com.sun.javafx.binding.StringFormatter;
import sun.text.normalizer.ICUBinary;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: anubhav
 * Date: 1/6/14
 * Time: 11:02 PM
 * To change this template use File | Settings | File Templates.
 */
public class UserAuthenticator {

    private Map<String, User> userList;

    public UserAuthenticator(Map<String, User> userList) {
        this.userList = userList;
    }

    public User authenticate(String libraryNumber, String password) {
        User user;
        try {
            user = userList.get(libraryNumber);
            if (user.getPassword().equals(password))
                return user;

        } catch (NullPointerException ex) {

            return null;
        }
        return null;
    }

}
